package com.lianzhihui.romeex.ui.me.dialog;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.ui.base.BaseDialog;
import com.lianzhihui.romeex.utils.ImagesUtil;
import com.lianzhihui.romeex.utils.MyToast;
import com.lianzhihui.romeex.utils.NoDoubleClickUtils;
import com.lianzhihui.romeex.utils.QrUtils.QRUtils;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @ProjectName: romeex
 * @Package: com.lianzhihui.romeex.ui.me.dialog
 * @ClassName: UpDateVersionDialog
 * @Description: java类作用描述
 * @Author: zhanghong
 * @CreateDate: 2020/11/3 10:40
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/11/3 10:40
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class VerificationCodeDialog extends BaseDialog {
    @BindView(R.id.et_input)
    EditText et_input;
    private Callback myCallback;

    public VerificationCodeDialog(@NonNull Context context) {
        super(context);

    }

    public VerificationCodeDialog(Context context, int style) {
        super(context, style);
    }

    @Override
    public void setCancelable(boolean flag) {
        super.setCancelable(flag);
    }

    public void setCallback(Callback myCallback) {
        this.myCallback = myCallback;
    }

    @Override
    public void show() {
        super.show();
    }

    @Override
    public void dismiss() {
        super.dismiss();
        if (null != this.myCallback) {
            this.myCallback.dialogDiss();
        }
        this.myCallback = null;
    }

    @Override
    protected int provideViewId() {
        return R.layout.dialog_verification_code;
    }

    @Override
    protected void initView() {

    }


    @OnClick({R.id.tv_confirm})
    public void OnClick(View v) {
        if (NoDoubleClickUtils.isDoubleClick()) {
            switch (v.getId()) {
                case R.id.tv_confirm:
                    if (et_input.getText().toString().trim().isEmpty()) {
                        MyToast.showToast(context.getResources().getString(R.string.text_input_verification_code));
                        return;
                    }
                    if (null != myCallback) {
                        myCallback.confirm(et_input.getText().toString().trim());
                    }
                    break;
                default:
                    break;
            }
        }
    }

    public static interface Callback {
        void confirm(String phoneNum);

        void dialogDiss();
    }


}
